<!-- 线路管理 - 综合表单页面 -->
<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption />
    <ex_super_table_page v-bind="option" ref="SuperTablePage" @selection-change="e => selection = e">
    </ex_super_table_page>

  </div>
</template>
<script>
import superTablePageFunction from '@/mixin/super-table-page-function';
import page_table_model_manage from '@/mixin/page_table_model_manage';
import emitOnFunction from '@/mixin/emit-on-function';
let emitKey = 'tms>line_manage'
export default {
  title: "label_line_manage",
  mixins: [superTablePageFunction, emitOnFunction(emitKey), page_table_model_manage],
  components: {},
  data() {
    return {
      selection: [],

      option: {
        search: {
          model: [
            { key: 'lineName', label: 'label_line_name' },
            // { key: 'lineOwner', label: 'label_line_owner', type: 'select', enum: 'LineOwnerEnum' },
            { key: 'status', label: 'label_line_status', type: 'select', enum: 'IsAvailableStatusEnum' },
            { key: 'originPlaceName', label: 'label_origin_place', },
            { key: 'destinationPlaceName', label: 'label_destination_place', },

          ],
        },
        actionExtra: [
          {
            label: 'label_add_logistics_route', attrs: { icon: "el-icon-plus", type: "primary" }, click: () => {
              this.$router.push({ path: '/page/tms/line/own_line_operate', query: { emitKey, } });
            }
          },
          { label: 'label_export', click: this.exportExcel },
        ],
        table: {
          url: "/tms-api/base/TmsLineInfoRpc/selectByPage.json",
          urlParams: { lineOwner: 'SELF_SUPPORT' },
          model: this.init_table_model(),
        }
      },

    };
  },
  methods: {
    option_table_model() {
      return [
        { type: 'selection', clickToggle: true, },

        { key: 'lineName', label: 'label_line_name', 'min-width': 120, 'show-overflow-tooltip': true, },
        { key: 'status', label: 'label_line_status', 'width': 120, 'show-overflow-tooltip': true, formatter: (r, c, v, i) => this.$enumShow(v, "IsAvailableStatusEnum") },
        { key: 'originPlaceName', label: 'label_origin_place', 'min-width': 120, 'show-overflow-tooltip': true, },
        { key: 'destinationPlaceName', label: 'label_destination_place', 'min-width': 120, 'show-overflow-tooltip': true, },
        // { key: 'lineOwner', label: 'label_line_owner', 'width': 120, 'show-overflow-tooltip': true, formatter: (r, c, v, i) => this.$enumShow(v, "LineOwnerEnum") },

        { key: 'gmtCreate', label: 'label_create_time', 'width': 130, 'show-overflow-tooltip': true, formatter: (r, c, v, i) => this.$dateFormat(v) },
        {
          type: 'operate', width: 170, operate: [
            {
              label: 'label_edit', click: (row) => {
                this.$router.push({ path: '/page/tms/line/own_line_operate', query: { id: row.id, emitKey, edit: true } });
              }
            },
            // {
            //   label: 'label_delete', type: "confirm-button",
            //   buttonClass: "button_text_danger", confirmButtonType: 'danger',
            //   url: '/tms-api/base/TmsLineInfoRpc/remove.json', message: 'text_confirm_sure_delete',
            //   params: (row) => { return { "id": row["id"] } }, done: ['reload', 'tip']
            // },
            {
              type: 'more',
              items: [
                {
                  label: 'label_view_detail', click: (row) => {
                    this.$router.push({ path: '/page/tms/line/own_line_detail', query: { id: row.id, } });
                  }
                },


              ]
            },
          ],
        }
      ]
    },
    exportExcel() {
      this.$downloadFile({
        loading: true,
        type: 'json',
        url: '/tms-api/base/TmsLineInfoRpc/exportExcel.json',
        data: {
          lineIds: this.selection.map(it => it.id),
          ...this.getSuperTablePage().getSearchFormData()
        },
      })
    },
  }
};

</script>
<style></style>
